<%@ page language="java" import="java.util.*,com.hs.app.model.*,com.hs.core.utils.*" pageEncoding="utf-8"%>
<%
  CdcTags catagory = (CdcTags)request.getAttribute("cdcobj");
  List catagorytype = (List)request.getAttribute("catagorytype");
  String tagtype = catagory == null?null:String.valueOf(catagory.getTagtype());
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html >
<head>
<%@ include file="../../include.jsp"%> 
<script src='<%=basePath%>dwr/interface/catagoryHelper.js'></script>   
<script>
function saveCatagory(){
	var cid = document.getElementById("cid").value;
	var tagtype = document.getElementById("tagtype").value;
	if('-1' == tagtype){
		alert("请选择分类类型！");
		return;
	}
	var cname = document.getElementById("tagname").value;
	var cnameng = document.getElementById("tagnameng").value; 
	if('' == cname){
		alert("分类名称不能为空！");
		return;
	}
    catagoryHelper.saveCatagory(cid,cname,cnameng,tagtype,callback4save);
}
function callback4save(data){
    document.getElementById("cid").value = data;
    alert("保存成功！");

}
</script>
</head>
<body>
    <div class="title">
    	<span><%=catagory==null?"新增":"修改"%>主题分类</span> 
    </div> 
      <table border="0" cellpadding="0" style="width:100%" cellspacing="0" class="tableForm"> 
        <tr>
          <th>类型:</th>
          <td colspan=3 nowrap>
             <input type="hidden" id="cid" value="<%=catagory==null?"":catagory.getId() %>" />
             <select name="tagtype" id="tagtype" style="width:99%">
	             <option value="-1" <%if("-1".equals(tagtype)){out.println(" selected");} %>>------全部------</option> 
	             <%
	             if(null != catagorytype){
	                for(int i=0;i<catagorytype.size();i++){
	                	Map data = (Map)catagorytype.get(i);
	                	String typename = (String)data.get("tagname");
	                	String typeid =  data.get("id") +"";
	                	%>
	               		<option value="<%=typeid%>" <%if(typeid.equals(tagtype)){out.println(" selected");} %>><%=typename%></option> 
	            <% } 
	            }
	           %>  
			  </select>
          </td> 
        </tr>
        <tr>
          <th>分类名称:</th>
          <td><input type="text" name="tagname" id="tagname" value="<%=catagory ==null?"":catagory.getTagname()%>" /></td>
          <th>英文名称:</th>
          <td><input type="text" name="tagnameng" id="tagnameng" value="<%=catagory ==null?"":catagory.getTagnameng()%>" /></td>
        </tr> 
        <tr>
          <th colspan="4">
          	 <input type="button" value="保存" onclick="saveCatagory();" class="btn" />
             <input type="button" onclick="window.close();" value="关闭" class="btn" />
          </th>
        </tr>
      </table> 
</body>
</html>
